/**
 * 2016年11月4日
 */
package jdk.effectivejava;

import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

/**
 * @author Alex
 *
 */
public class StopThread {
	private static boolean stop;
	private static synchronized void requestStop(){
		stop = true;
	}
	private static synchronized boolean status(){
		return stop;
	}
	public static void main(String arg[]) throws InterruptedException{
		Semaphore s = new Semaphore(2);
		Thread t = new Thread(()->{
			int i = 0;
			while(!status()){
				i++;
			}
		
		});
		t.start();
		TimeUnit.SECONDS.sleep(1);
		requestStop();
		
		
	}
}
